var ffi = require('ffi');

try {
    window.dll = require('ffi').Library('server/MessMiddle.dll', {
        'Init': ['int', []], // 初始化环境
        'OpenIDCard': ['int', ['string']], // 打开设备，参数可变，CardReader310
        'ReadCard': ['int', ['string']], // 读取卡片信息，参数可变，
        'EjectCard': ['int', []] // 退卡

    })
    // if (dll.Init() === 0) {
    //     console.log('aaa===', dll.OpenIDCard('sfz'))
    // }
} catch (error) {
    console.error('ffi.Library', error);
}

const init = function() {
    //console.log('初始化')
    //console.log(dll.Init())
    console.log(dll.Init())
}

const opendev = function() {
    console.log('打开')
    let cardNo = 'sfz'
    console.log(dll.OpenIDCard(cardNo))
}

const readCard = function() {
    console.log('读卡')
    let cardNo = ''
    console.log(dll.ReadCard(cardNo))
}

const checkOut = function() {
    console.log('退卡')
    console.log(dll.EjectCard())
}
